package com.kaishengit.service;

import java.util.List;

import com.kaishengit.dao.ContactDao;
import com.kaishengit.entity.Contact;
import com.kaishengit.entity.UserProject;
import com.kaishengit.util.DateUtil;
import com.kaishengit.util.PkUtil;

public class ContactService {
	private ContactDao contactDao=new ContactDao();

	public void save(String name, String company, String cellphone,String phone, String email, String address, 
		String website,String weibo, String introduction,UserProject userProject) {
				Contact c=new Contact();
				c.setId(PkUtil.getId());
				c.setName(name);
				c.setCompany(company);
				c.setCellphone(cellphone);
				c.setAddress(address);
				c.setCreatetime(DateUtil.getNowDateTime());
				c.setEmail(email);
				c.setIntroduction(introduction);
				c.setPhone(phone);
				c.setWebsite(website);
				c.setWeibo(weibo);
				c.setProject(userProject.getProject());
				c.setProjectId(userProject.getProject().getId());
				contactDao.save(c);
	}

	public List<Contact> findByProjectId(String projectId) {
		return contactDao.findByProjectId(projectId);
		
	}

	public Contact findById(String id) {
		return contactDao.findById(id);
	}

	public void update(String id, String name, String company,String cellphone, String phone, String email, String address,
			String website, String weibo, String introduction) {
		 contactDao.update(id,name,company,cellphone,phone,email,address,website,weibo,introduction);
		
	}

	public void del(String id) {
		contactDao.del(id);
		
	}

}
